package Turma.Jogo;

import android.framework.*;
import android.framework.Graphics.PixmapFormat;

public class PlayerArkanoid extends GameObject
{
	Game game;
	private float velocidade = 500;
	
	public PlayerArkanoid(int x, int y, int w, int h, Game game)
	{
		super(game.getGraphics(), "barra.png", PixmapFormat.ARGB4444, x, y, w, h);
		this.game = game;
	}
	
	public void update(float deltaTime)
	{
		
		float accelX = -this.game.getInput().getAccelY();

		if (accelX > 0.2f)
		{
			this.x -= this.velocidade * deltaTime;
		}
		else if (accelX < -0.2f)
		{
			this.x -= -this.velocidade * deltaTime;
		}
		
		if (this.x < 0)
		{
			this.x = 0;
		}
		else if (this.x + this.image.getWidth() > game.getGraphics().getWidth())
		{
			this.x = game.getGraphics().getWidth() - this.image.getWidth();
		}
	}
}
